<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>user-update</title>
</head>

<link rel="stylesheet" href="../css/css1.css" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/validate.js"></script>
<script type="text/javascript" src="../js/myValidate.js"></script>
<script type="text/javascript">
<!--
function updateComplete() {
	var updateFlag = document.getElementById('updateFlag').value;
	if(updateFlag == '1') {
		alert('update succeed!');
	} else if(updateFlag = '0') {
		alert('update failed!');
	} else {
		alert('unknown result!');
	}
	window.opener.location.reload();
	window.close();
}

// var jsonObj = {"key":"value",items:[{key1:"key1Value"},{key2:"key2Value"}]}

// alert(jsonObj.key);
// alert(jsonObj.items[0].key1);

//vb dim
// var a = "a";
// a = 'a'
// a = 1
// a = false

// typeof a == "string" 

// var b = a || "b";

// function x(a,b)
// arguments.length

// x("xxx","3434")


-->
</script>
<body>
<f:view>
<h:inputHidden id="updateFlag" value="#{UserManagedBean.updateFlag }"></h:inputHidden>
<h:form id="updateForm">
<!-- 是否更新成功1:succeed  0:failed -->
<h:inputHidden id="updateFlag" value="#{UserManagedBean.updateFlag }"></h:inputHidden>

<!-- 调bean方法的update按钮 -->
<a4j:commandButton id="updateBtn" 
				   style="display:none"
				   action="#{UserManagedBean.updateByPK() }"
				   reRender="updateFlag"
				   oncomplete="updateComplete();"
				   	>
</a4j:commandButton>
	<table id="updateTable" >
		<tr>
			<td>
				<h:outputText>name</h:outputText>
			</td>
			<td>
				<h:inputText id="name" value="#{UserManagedBean.user.name }"/>
			</td>	
			<td>
				<h:outputText>password</h:outputText>
			</td>
			<td>
				<h:inputText id="password" value="#{UserManagedBean.user.password }"/>
			</td>		
		</tr>
		<tr>
			<td>
				<h:outputText>gender</h:outputText>
			</td>
			<td>
				<h:inputText id="gender" value="#{UserManagedBean.user.gender }"/>
			</td>			
			<td>
				<h:outputText>email</h:outputText>
			</td>
			<td>
				<h:inputText id="email" value="#{UserManagedBean.user.email }"/>
			</td>		
		</tr>	
		<tr>
			<td>
				<h:outputText>permission</h:outputText>
			</td>
			<td>
				<h:inputText id="permission" value="#{UserManagedBean.user.permission }"/>
			</td>	
			<td>
				<h:outputText>status</h:outputText>
			</td>
			<td>
				<h:inputText id="status" value="#{UserManagedBean.user.status }"/>
			</td>	
		</tr>	
		<tr>
			<td>
				<h:outputText>birthdate</h:outputText>
			</td>
			<td class="TxtLeft">
				<rich:calendar id="birthdate" 
					value="#{UserManagedBean.user.birthdate }"
					isDayEnabled="preventAheadTime"
					datePattern="yyyy-MM-dd" popup="true" inputSize="23"
					inputClass="inputText" enableManualInput="false" />
			</td>	
			<td>
				<h:outputText>registertime</h:outputText>
			</td>
			<td class="TxtLeft">
				<rich:calendar id="registertime" 
					value="#{UserManagedBean.user.registertime }"
					isDayEnabled="preventAheadTime"
					datePattern="yyyy-MM-dd" popup="true" inputSize="23"
					inputClass="inputText" enableManualInput="false" />
			</td>						
		</tr>	
		<tr>
			<td colspan="4" align="center">
			<!-- 	也可以这样做,
				<input type="button" id="update" value="update" 
					   style="btn"
					   onclick="updateBtnClick()"
					   onmouseover="mOverBtn(this,'Find')"
					   onmouseout="mOutBtn(this,'Find')">
		    -->
   				<a4j:commandButton id="update" value="update" 
					   styleClass="btn"
					   onclick="updateBtnClick()"
					   onmouseover="mOverBtn(this,'Find')" 
					   onmouseout="mOutBtn(this,'Find')"/>
			</td>
		</tr>			
	</table>
</h:form>
</f:view>
</body>
<script type="text/javascript">
<!--
function updateBtnClick() {
	document.getElementById('updateForm:updateBtn').click();
}
-->
</script>
</html>